<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=utf-8" import="com.*"%>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
	    <title>制卡批次信息维护</title>
	    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	    
	    <script src="${pageContext.request.contextPath }/scripts/boot.js" type="text/javascript"></script>
	    <style type="text/css">
    	
	    </style> 
  </head>
  
  <body>
   <form id="form1" method="post">
   	 <!-- ============================== 第一部分 查询================================================== -->
     <div style="width:100%;align:center;">
     	<table style="width:100%;align:center;">
     		<tr style="width:100%;align:center;">
 	    			<td style="width:30%;text-align:right;">制卡批次:</td>
 	    			<td style="width:35%;"><input id="key" name="key" class="mini-textbox" vtype="minLength:10" maxLength="10"  onenter="search" style="width:100%;" emptyText="请输入10位制卡批次，以GR或DW开始..." required="true" maxLength="10"/></td>
 	    			<td style="width:10%;text-align: left; white-space:nowrap;">
          			<a class="mini-button" iconCls="icon-search"  onclick="search()">查询</a>
          			<a class="mini-button" iconCls="icon-remove"  onclick="onReset()">重置</a>
          			</td>
          			<td style="width:25%"></td>
 	    	</tr>
     	</table>
     </div>
     
   
 	 <!-- ============================== 第二部分 制卡界面信息================================================== -->
 	 <fieldset style="border:solid 1px #aaa;width:97%;height: 100%;align:center;" >
 	 	<legend><span style="color:black;">制卡详细信息</span></legend>
 	    <div style="width:100%;">
 	    	<table style="width:100%;" cellpadding="5">
 	    		<tr style="width:100%;">
 	    			<td style="width:30%;text-align:right;">制卡批次:</td>
 	    			<td style="width:70%;"><input id="aaz001" name="aaz001" class="mini-textbox" style="width:60%;" inputStyle="background:rgb(241,241,243)" allowInput="false" readonly="true"/></td>
 	    		</tr>
 	    		<tr style="width:100%;">
 	    			<td style="width:30%;text-align:right;">生效时间:</td>
 	    			<td style="width:70%;"><input id="aaz707" name="aaz707" class="mini-datepicker"  style="width:60%;" inputStyle="background:rgb(241,241,243)" allowInput="false" readonly="true"/></td>
 	    		</tr>
 	    		<tr style="width:100%;">
 	    			<td style="width:30%;text-align:right;">领取时间:</td>
 	    			<td style="width:70%;"><input id="aaz708" name="aaz708" class="mini-datepicker"  style="width:60%;" inputStyle="background:rgb(241,241,243)" allowInput="false" readonly="true"/></td>
 	    		</tr>
 	    		<tr style="width:100%;">
 	    			<td style="width:30%;text-align:right;">是否特殊批次:</td>
 	    			<td style="width:70%;"><input id="aaz719" name="aaz719" class="mini-textbox" data="[{id: 1, text: '是'}, {id: 2, text: '否'}]" style="width:60%;" valueField="bm" textField="mch" inputStyle="background:rgb(241,241,243)" allowInput="false" readonly="true"/></td>
 	    		</tr>
 	    		<tr style="width:100%;">
 	    			<td style="width:30%;text-align:right;">批次录入人:</td>
 	    			<td style="width:70%;"><input id="aae300" name="aae300" class="mini-textbox" style="width:60%;"   inputStyle="background:rgb(241,241,243)" allowInput="false" readonly="true" /></td>
 	    		</tr>
 	    		<tr style="width:100%;">
 	    			<td style="width:30%;text-align:right;">批次录入时间:</td>
 	    			<td style="width:70%;"><input id="aaz402" name="aaz402" class="mini-datepicker"  style="width:60%;"  inputStyle="background:rgb(241,241,243)" allowInput="false" readonly="true"/></td>
 	    		</tr>	    		
 	    	</table>
 	    </div>
 	 </fieldset>
 	</form> 
 	 <!-- ============================== 第三部分 按钮================================================== -->
 	 <br/>
	    <div>
	    	<table style="table-layout:fixed;width:100%;" cellpadding="0" cellspacing="10">
	    		<tr style="width:100%;">
	    		 <td style="width:46%;white-space:nowrap;"></td>
			     <td style="width:8%;white-space:nowrap;"><a class="mini-button" onclick="onOk" id="onoks" enabled="false" style="width:100%;" iconCls="icon-ok"/>终止批次</td>
			     <td style="width:46%;"></td>
	    		</tr>
	    	</table>
	    </div> 
   
   
   <script type="text/javascript">
   		mini.parse();
   		var form = new mini.Form("form1");
        var today = new Date();
   		/* var now = today.getFullYear() + "-" +today.getMonth() +"-"+ today.getDay(); */
        mini.getbyName("aaz706").setValue(today);  		
           		
   		  function check() {
            var aaz001 = mini.getbyName("key").getValue().trim();
           $.ajax({
                  url: "${pageContext.request.contextPath}/AZ10.do?method=chkAZ10",
                  type: 'post',
                  data: { aaz001: aaz001},
                  cache: false,
                  success: function (text) {
	                  if(text == 0){
	                  	search();
	                  }
	                 else{
	                 	mini.alert(text);
	                 }
                  },
                  error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                    CloseWindow();
                  }
              });
        } 
         
        function search(){
        	var aaz001 = mini.getbyName("key").getValue().trim();
        	var flag = aaz001.substring(0,2);
        	mini.getbyName("key").setEnabled(false);
        	if(aaz001 == ""){
        		mini.alert("请输入查询批次号！");
        		mini.getbyName("key").setEnabled(true);
        		return ;
        	}
        	if(flag != 'GR' && flag != 'DW'){
        		mini.alert("请输入以GR或者DW开头的十位制卡批次！");
        		form.clear();
        		mini.getbyName("key").setEnabled(true);
        		return ;
        	}
        		$.ajax({
	                url: "${pageContext.request.contextPath}/AZ10.do?method=getAZ10Data&id=" + aaz001,
	                cache: false,
	                success: function (text) {
	                    var o = mini.decode(text);
	                    if(o.msg == "1")
	                    {
	                        mini.alert("该制卡批次已终止");
	                        form.clear();
	                        mini.getbyName("key").setEnabled(true);
	                        return;
	                    }
	                    if(o.msg == "2") 
	                    {
	                       mini.alert("无此制卡批次");
	                       form.clear();
	                       mini.getbyName("key").setEnabled(true);
	                       return;
	                    }
	                   if(o.msg == "0") {	
	                    mini.get("onoks").setEnabled(true);                		
	                    mini.getbyName("aaz001").setValue(o.aaz001);
	                    mini.getbyName("aaz707").setValue(o.aaz707);
	                    mini.getbyName("aaz708").setValue(o.aaz708);
	                    mini.getbyName("aaz719").setValue(o.aaz719);
	                    mini.getbyName("aae300").setValue(o.aae300);
	                    mini.getbyName("aaz402").setValue(o.aaz402); 
	                	}
	                }
                });
        	
        }
        
   		function onOk(e) {
             endData();
        }
        function onReset(){
            mini.get("onoks").setEnabled(false);
        	form.clear();
        	mini.getbyName("key").setEnabled(true);
        }
        function endData() {
            var o = form.getData();
            form.validate();
            if (form.isValid() == false){
            	return;
            	} 
            	 if(form.isValid()==true){
      	    	mini.mask({el: document.body,cls: 'mini-mask-loading',html: '保存中...'});  
           var json = mini.encode([o]);
           $.ajax({
                  url: "${pageContext.request.contextPath}/AZ10.do?method=endAZ10",
                  type: 'post',
                  data: { data: json},
                  cache: false,
                  success: function (text) {
                   mini.unmask();
                  	mini.alert(text);
                  	mini.get("onoks").setEnabled(false);
                  	mini.getbyName("key").setEnabled(true);
                  	form.clear();
                  },
                  error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                    CloseWindow();
                  }
              });
        }
   		}
    	
   </script>
   
  </body>
</html>
